package com.alibaba.citrus.ots.platform.enhance.functions.diff.sap.dataParser;

import com.alibaba.citrus.ots.platform.enhance.functions.diff.common.constant.SalesOrderLineDiffStandardFieldDict;
import com.alibaba.citrus.ots.platform.enhance.functions.diff.common.dataParser.DataParser;
import com.alibaba.citrus.ots.platform.enhance.repository.model.diff.common.FieldLineDTO;
import com.alibaba.cz.base.tool.log.Log;
import com.epoch.app.otsapplicationadaptersdk.sap.MnReceiverCommDetails;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author hanguo
 * @date 2022/1/25
 * @Description SapIf006SDODetail数据解析
 */
@Component
public class SapIf006SDODetailDataParse extends DataParser {

    /**
     * 日志
     */
    private static Log log = Log.getLogger(SapIf006SDODetailDataParse.class);

    /**
     * 数据库字段，映射成对账处理的业务字段(标准字段)
     * key：报文中的字段，value：转换后的字段,这里的 value 字段也不要重复
     */
    private static Map<String, String> dataBaseFiledMapping = new HashedMap();

    static {
        dataBaseFiledMapping.put("outerItemKey", SalesOrderLineDiffStandardFieldDict.SAP_SALES_ORDER_LINE_ID.getFieldCode());
        dataBaseFiledMapping.put("itemKey",SalesOrderLineDiffStandardFieldDict.SERIAL_NUMBER.getFieldCode());


    }


    @Override
    public Map<String, FieldLineDTO> parse(Object obj) {
        Map<String, FieldLineDTO> map = new HashMap<>();
        if (obj instanceof MnReceiverCommDetails) {
            MnReceiverCommDetails mnReceiverCommDetails = (MnReceiverCommDetails) obj;
            return obtainFieldLineMap(dataBaseFiledMapping, mnReceiverCommDetails, mnReceiverCommDetails.getClass());
        }
        return map;
    }

    @Override
    public String obtainProcessType() {
        return "MnReceiverCommDetails";
    }
}
